/*
 * This file is part of andExplorer, android.ovhoo.com
 * Copyright (C) 2007 Mohamed ZALIM <mzalim@ovhoo.com>
 *
 * andExplorer is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 3 of the License, or
 * (at your option) any later version.
 *
 * andExplorer is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/gpl.html>.
 */
package com.ovhoo.android.fiveexplore;


import com.ovhoo.android.fiveexplore.R;

import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.view.Window;
import android.view.View.OnClickListener;
import android.widget.*;
import android.widget.AdapterView.OnItemClickListener;

public class FieExplorer extends Activity implements OnClickListener, OnItemClickListener {
	
	private GridView contentView;
	private ContentAdapter contentAdapter;
	private TextView curentDirPath;
	private ImageButton go_upButton;
	
	private Button toolButtonCreateDir = null;

	
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        //Hide title bar
        requestWindowFeature(Window.FEATURE_NO_TITLE);
        
        setContentView(R.layout.main);
               
        
        //Load component
        this.contentView = (GridView) findViewById(R.id.MAIN_CONTENT_VIEW);
        this.toolButtonCreateDir = (Button) findViewById(R.id.MAIN_TOOLS_CREATE_DIR);
        this.curentDirPath = (TextView) findViewById(R.id.MAIN_TEXT_PATH);
        this.go_upButton = (ImageButton) findViewById(R.id.MAIN_PATH_GO_UP);

        this.contentAdapter = new ContentAdapter(this, "/sdcard/Mes.Docs",this.curentDirPath );
        this.contentView.setAdapter(this.contentAdapter);
        
        //Addlistener
        this.toolButtonCreateDir.setOnClickListener(this);
        this.go_upButton.setOnClickListener(this);
        
        this.contentView.setOnItemClickListener(this);
        
   }


	@Override
	public void onClick(View view) {
		if (view == (View) this.toolButtonCreateDir){
			this.contentAdapter.createDirectory();	
		}
		else if(view == (View) this.go_upButton){
			this.contentAdapter.go_up();	
		}
		
	}


	@Override
	public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
		this.contentAdapter.onItemClicked(view,position,id);
		
	}
    
	

    
    
}